
function cambiar_login() {
  document.querySelector('.cont_forms').className = "cont_forms cont_forms_active_login";  
document.querySelector('.cont_form_login').style.display = "block";
document.querySelector('.cont_form_sign_up').style.opacity = "0";               

setTimeout(function(){  document.querySelector('.cont_form_login').style.opacity = "1"; },400);  
  
setTimeout(function(){    
document.querySelector('.cont_form_sign_up').style.display = "none";
},200);  
  }

function cambiar_sign_up(at) {
  document.querySelector('.cont_forms').className = "cont_forms cont_forms_active_sign_up";
  document.querySelector('.cont_form_sign_up').style.display = "block";
document.querySelector('.cont_form_login').style.opacity = "0";
  
setTimeout(function(){  document.querySelector('.cont_form_sign_up').style.opacity = "1";
},350);

setTimeout(function(){   document.querySelector('.cont_form_login').style.display = "none";
},300);


}    



function ocultar_login_sign_up() {

document.querySelector('.cont_forms').className = "cont_forms";  
document.querySelector('.cont_form_sign_up').style.opacity = "0";               
document.querySelector('.cont_form_login').style.opacity = "0"; 

setTimeout(function(){
document.querySelector('.cont_form_sign_up').style.display = "none";
document.querySelector('.cont_form_login').style.display = "none";
},500);  
  
 }

function loginajax(){

        var phone_email = document.getElementById("phone_email").value;
        var password = document.getElementById("password").value;

        if(phone_email==null||phone_email==''){

               document.getElementById("phone_email").setAttribute("placeholder","请输入邮箱");
               document.getElementById("phone_email").focus();
               return;
        }
         if(password==null||password==''){
               document.getElementById("password").setAttribute("placeholder","请输入密码");
               document.getElementById("password").focus();
               return;
        }
        //获得ajax引擎
          var xmlhttp;
          if (window.XMLHttpRequest)
          {
            // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlhttp=new XMLHttpRequest();
          }
          else
          {
            // IE6, IE5 浏览器执行代码
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          }




         xmlhttp.onreadystatechange=function(){
             if(xmlhttp.readyState==4 && xmlhttp.status==200){
                		//服务器响应有两种类型  一种为responseText（String 类型）一种是responseXml类型
                		var data=xmlhttp.responseText;
                		if(data == "index"){
                		     window.location.href = data;
                               document.getElementById("ts").innerHTML='';
                		}else{
                		     document.getElementById("ts").innerHTML=data;

                		}




             }
        }
        xmlhttp.open("post","/get_login?phone_email="+phone_email+"&password="+password,true);

        xmlhttp.send(null);

}
var countdown=60;
var phone_code = 123;
function get_code(val){

               //获得ajax引擎
               if(phone.value.length<11&&phone.value.length>0||phone.value.length>11){
                    phone.value='';
                    phone.setAttribute("placeholder","手机号输入有误!");
                    phone.focus();

                    disabled = 0;
                    return;

               }
//              var xmlhttp;
//              if (window.XMLHttpRequest)
//              {
//                // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
//                xmlhttp=new XMLHttpRequest();
//              }
//              else
//              {
//                // IE6, IE5 浏览器执行代码
//                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
//              }
//
//
//
//
//             xmlhttp.onreadystatechange=function(){
//                 if(xmlhttp.readyState==4 && xmlhttp.status==200){
//                    		//服务器响应有两种类型  一种为responseText（String 类型）一种是responseXml类型
//                    		phone_code =xmlhttp.responseText;
//
//
//
//
//                 }
//            }
//            xmlhttp.open("post","/get_login?phone_email="+phone_email+"&password="+password,true);
//
//            xmlhttp.send(null);

            if(phone.value==null||phone.value==''){
                      phone.setAttribute("placeholder","请输手机号!");
                      phone.focus();
                      disabled = 0;
                      return;

            }
            if (countdown == 0) {
                val.style.backgroundColor ='#f44336';
                val.removeAttribute("disabled");
                val.innerHTML="获取验证码";
                phone.readOnly = false;
                countdown = 60;
                disabled = 0;
            } else {
                val.style.backgroundColor ='#B0B0B0';
                phone.readOnly = true;
                val.setAttribute("disabled", true);
                val.innerHTML="重新发送("+countdown+")s";
                countdown--;
                setTimeout(function() {
                    get_code(val)
                },1000)
            }




    console.log(val.value);
}

//提交用户注册信息
function sub_user(){

        var phone = document.getElementById("phone");
        var email = document.getElementById("email");
        var security_code = document.getElementById("security_code");
        var pwd = document.getElementById("pwd");
        var rpwd = document.getElementById("rpwd");
        console.log(email.value)
        //非空验证
        if(phone.value==null||phone.value==''){
            phone.setAttribute("placeholder","请输手机号!");
            phone.focus();
            return false;

        }
        if(email.value==null||email.value==''){
            email.setAttribute("placeholder","请输入邮箱地址!");
            email.focus();
            return false;
        }
        if(security_code.value==null||security_code.value==''){
            security_code.setAttribute("placeholder","请输入验证码!");
            security_code.focus();
            return false;
        }
        if(pwd.value==null||pwd.value==''){
            pwd.setAttribute("placeholder","请输入密码!");
            pwd.focus();
            return false;
        }
        if(rpwd.value==null||rpwd.value==''){
            rpwd.setAttribute("placeholder","请再次输入密码!");
            rpwd.focus();
            return false;
        }
        //邮箱格式
        if(true){


        }
        if(security_code.value!=phone_code){
            security_code.value=null;
            security_code.setAttribute("placeholder","验证码错误!");
            security_code.focus();
            return false;
        }
        if(pwd.value!=rpwd.value){
            rpwd.value=null;
            rpwd.setAttribute("placeholder","两次密码不一致!");
            rpwd.focus();
            return false;
        }


}